<?php
/**
 * @file Registry.php
 *
 * Registry for global settings.
 *
 * Like every registry this class can contain variables / settings that have
 * global scope. It should be used by it's
 *
 * http://code.google.com/p/rpd/wiki/Registry
 *
 * New BSD License
 * \n
 * Copyright (c) 2010 Rpd-Team
 *
 * @namespace  rpd
 * @since      0.0.1
 * @version    0.0.1
 */

/**
 * @todo short desc for Registry.php
 * @since  0.0.9
 *
 * @todo long desc for Registry.php
 *
 *
 * @section Changelog
 *
 * <table>
 * 	<tr>
 * 		<th>Version</th>
 * 		<th>Description</th>
 *  </tr>
 *  <tr><td>0.1.0</td><td>Can use ini file</td></tr>
 * </table>
 *
 *
 * @section Examples
 *
 * @subsection Registry_Get_Set Set and get
 *
 * <pre>/app/Controller/index.php</pre>
 * @code
 * <?php
 *
 * // store in Registry
 * Registry::set("some/path/as/an/id", "some information");
 *
 * // get from Registry
 * echo Registry::get("some/path/as/an/id");
 *
 * ?>
 * @endcode
 *
 * <pre>Output "/"</pre>
 * @verbatim some information @endverbatim
 *
 *
 *
 */
class Registry {
	protected static $List;

	public static function get($name, $item = NULL) {
		if ($item === NULL)
		{
			return self::$List[strtolower($name)];
		}
		else
		{
			return self::$List[strtolower($name)][$item];
		}
	}

	public static function set($name, $value) {
		self::$List[strtolower($name)] = $value;
	}

	public static function prepend($name, $value)
	{
		$name = strtolower($name);
		self::$List[$name] = array_merge((array) $value, self::$List[$name]);
	}

	public static function append($name, $value)
	{
		$name = strtolower($name);
		self::$List[$name][] = $value;
	}

	/**
	 *
	 * Use information from INI-File
	 * @param filename $file
	 * @since 0.1.0
	 */
	public static function parse_ini_file($file)
	{
		self::$List = parse_ini_file($file, true);
	}
}

?>